﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using RED_NET_Core.Helper;

namespace RED_NET_Core.Entity
{
    public class ErrorInfo
    {
        private int _id;
        private string _Info;
        private DateTime _occurTime;
        private int _uId;

        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }
        public string Info
        {
            get {return  _Info; }
            set { _Info = value; }
        }
        public DateTime OccurTime
        {
            get { return _occurTime; }
            set { _occurTime = value; }
        }
        public int UId
        {
            get { return _uId; }
            set { _uId = value; }
        }
        public int AddItem()
        {
            int _id = -1;
            SqlParameter[] _param = new SqlParameter[3];

            _param[0] = new SqlParameter("@Info", _Info.ToString());
            _param[1] = new SqlParameter("@OccurTime", _occurTime.ToString());
            _param[2] = new SqlParameter("@UId", _uId.ToString());
            string _smdStr = "insert into _ErrorInfo(_Info,_OccurTime,_UId) values(@Info,@OccurTime,@UId) SELECT   SCOPE_IDENTITY()   as   '_Id'";
            OwnSqlHelper _shp = new OwnSqlHelper();
            try
            {
                _id = Int32.Parse(_shp.ExecuteScalar(_smdStr, _param));
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return _id;

        }
    }
}
